package com.blog.cloud.api.feign;

import com.blog.cloud.api.dto.UserInfoDTO;
import com.blog.cloud.api.dto.UserRegisterDTO;
import com.blog.cloud.api.utils.R;
import jakarta.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * OpenFeign客户端，调用blog-cloud-service的UserService接口
 * 使用参考官网文档 https://spring.io/projects/spring-cloud-openfeign
 *
 * @author 龙茶清欢
 * @since 2024-08-23 20:35:06
 */
@FeignClient(contextId = "remoteUserService", value = "blog-cloud-service")
public interface RemoteUserService {

    @PostMapping("/user/findUserByUsername")
    R<UserInfoDTO> findUserByUsername(@RequestBody String username);

    @PostMapping("/user/findUserByMobile")
    R<UserInfoDTO> findUserByMobile(@RequestBody String mobile);

    @PostMapping("/user/findUserByFlag")
    R<UserInfoDTO> findUserByFlag(@RequestBody @Valid UserRegisterDTO registerDto);

    @PostMapping("/user/saveUser")
    R<Boolean> saveUser(@RequestBody @Valid UserRegisterDTO registerDto);

}

// 也可以使用 SpringBoot 提供的 WebClient、RestTemplate 等进行远程调用，具体参考 SpringBoot 官方文档： https://docs.spring.io/spring-boot/reference/io/rest-client.html
// 关于远程调用的使用可以参考 SpringBoot 官方文档： https://docs.spring.io/spring-boot/reference/io/rest-client.html